<!DOCTYPE html>
<html>
<head>
    <style>
        /* 提交按钮样式 */
        .submit-button {
            width: 120px;
            height: 40px;
            background-color: #4CAF50;
            color: #fff;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        /* 进度条样式 */
        .progress-bar {
            position: absolute;
            top: 0;
            right: 0;
            height: 100%;
            background-color: #f1f1f1;
            width: 0;
            transition: width 0.5s ease-in-out;
        }
    </style>
</head>
<body>
<form id="myForm">
    <!-- 表单内容 -->
    <input type="text" name="name" placeholder="姓名">
    <input type="email" name="email" placeholder="邮箱">
    <button type="submit" class="submit-button">
        提交
        <div id="progressBar" class="progress-bar"></div>
    </button>
</form>

<script>
    document.getElementById("myForm").addEventListener("submit", function (event) {
        event.preventDefault(); // 阻止表单默认提交行为


        const progressBar = document.getElementById("progressBar");
        progressBar.style.width = "100%"; // 设置初始进度为100%

        // 模拟进度更新，每1秒减少10%
        let progress = 100;
        const intervalId = setInterval(function () {
            progress -= 10;
            progressBar.style.width = progress + "%";
            if (progress === 0) {
                clearInterval(intervalId);
                // 在这里执行提交表单的操作
                // 例如：document.getElementById("myForm").submit();
            }
        }, 1000);
    });
</script>
</body>
</html>